#!/usr/bin/env ruby
require 'erb'

require 'session'

TMPL = <<EOF
class <%= class_name.snake_case.camel_case %> < ActiveRecord::Base
end
EOF

if ARGV.size == 0
  puts 'usage new_model MyNewModel or my_new_model'
  exit -1
end

class_name = ARGV[0]
filename = format(Dir.pwd+"/models/%s.rb", class_name.snake_case)
if File.exists?(filename)
  puts "file '#{filename}' already exists! bailing out..."
  exit -1
else
  File.open(filename, 'w+') do |file|
    file.write ERB.new(TMPL).result(binding)
  end
  puts "#{filename} created"
end


